package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.User;
import org.apache.ibatis.annotations.*;

public interface UserDao {
    public User findByUsername(String username);

    Page<User> findPage(String queryString);

    @Select("select * from t_user where id=#{id}")
    User findById(Integer id);

    void edit(User user);
    @Delete("delete from t_user_role where user_id=#{id} ")
    void deleteByUserId(Integer id);

    @Insert("insert into t_user_role values(#{userId},#{id})")
    void addId(@Param("userId") Integer userId,@Param("id") Integer id);

    @Insert("insert into t_user values(#{id},#{birthday},#{gender},#{username},#{password},#{remark},#{station},#{telephone})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    void add(User user);

    @Insert("insert into t_user_role values(#{userId},#{id})")
    void addMidId(@Param("userId") Integer userId,@Param("id") Integer id);

    @Delete("delete from t_user where id=#{id} ")
    void delete(Integer id);
}
